﻿# common variables
@coa_width = 768
@coa_height = 512
@canton_scale_cross_x = @[ ( 333 / coa_width ) + 0.001 ]
@canton_scale_cross_y = @[ ( 205 / coa_height ) + 0.001 ]
@canton_scale_sweden_x = @[ ( 255 / coa_width ) + 0.001 ]
@canton_scale_sweden_y = @[ ( 204 / coa_height ) + 0.001 ]
@canton_scale_norway_x = @[ ( 192 / coa_width ) + 0.001 ]
@canton_scale_norway_y = @[ ( 192 / coa_height ) + 0.001 ]
@canton_scale_denmark_x = @[ ( 220 / coa_width ) + 0.001 ]
@canton_scale_denmark_y = @[ ( 220 / coa_height ) + 0.001 ]
@third = @[1/3]

## East Asia flag definitions ##

CHI = { # China
	flag_definition = {
		coa = CHI_han_empire
		coa_with_overlord_canton = CHI_han_empire
		priority = 25
		trigger = { 
			exists = scope:actor
			scope:actor = {
				NOT = { country_has_primary_culture = cu:manchu }
				has_law = law_type:law_monarchy
			}
		}
	}
	flag_definition = {
		coa = CHI
		subject_canton = CHI
		coa_with_overlord_canton = CHI_subject
		allow_overlord_canton = yes		
		priority = 1
	}
	flag_definition = {
		coa = CHI_absolute_monarchy
		subject_canton = CHI_absolute_monarchy
		coa_with_overlord_canton = CHI_subject
		allow_overlord_canton = yes				
		priority = 20
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = CHI_republic
		subject_canton = CHI_republic
		allow_overlord_canton = yes
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = CHI_dictatorship
		subject_canton = CHI_dictatorship
		priority = 20
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = CHI_theocracy
		subject_canton = CHI_theocracy
		subject_canton = CHI_absolute_monarchy
		priority = 20
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = CHI_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}		
	
	# WB anarchist flags
	flag_definition = {
		coa = CHI_anarchist
		subject_canton = CHI_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}

JAP = { # Japan
	flag_definition = {
		coa = JAP
		allow_overlord_canton = yes		
		coa_with_overlord_canton = JAP_subject			
		subject_canton = JAP
		priority = 1		
	}
	flag_definition = {
		coa = JAP_rising_sun
		subject_canton = JAP_rising_sun		
		priority = 10
		trigger = {
			coa_def_military_junta_flag_trigger = yes
		}
	}
	flag_definition = {
		coa = JAP_tokugawa
		allow_overlord_canton = yes	
		subject_canton = JAP_tokugawa_naval_jack # the Nakaguro flag
		
		coa_with_overlord_canton = JAP_tokugawa_subject
		overlord_canton_scale = { 0.37 0.37 }
		
		priority = 20
		trigger = {
			exists = scope:actor
			scope:actor = { NOT = { has_variable = meiji_var } }
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}
	flag_definition = {
		coa = JAP_tokugawa_late
		allow_overlord_canton = yes	
		subject_canton = JAP_tokugawa_naval_jack # the Nakaguro flag
		
		coa_with_overlord_canton = JAP_tokugawa_subject_alt
		overlord_canton_scale = { 0.37 0.37 }
		
		priority = 20
		trigger = {
			exists = scope:actor
			scope:actor = { NOT = { has_variable = meiji_var } }
			coa_def_absolute_monarchy_flag_trigger = no
			coa_def_monarchy_flag_trigger = yes
		}
	}
	flag_definition = {
		coa = JAP_absolute_monarchy
		subject_canton = JAP_absolute_monarchy
		coa_with_overlord_canton = JAP_subject
		priority = 20
		trigger = {
			exists = scope:actor
			scope:actor = { has_variable = meiji_var }
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}
	flag_definition = {
		coa = JAP_republic
		subject_canton = JAP_republic
		allow_overlord_canton = yes
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
		
		# WB edits
		coa_with_overlord_canton = JAP_republic_subject
		overlord_canton_scale = { 0.45 0.45 }
	}	
	flag_definition = {
		coa = JAP_dictatorship
		subject_canton = JAP_dictatorship
		allow_overlord_canton = yes
		coa_with_overlord_canton = JAP_subject
		priority = 20
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = JAP_theocracy
		subject_canton = JAP_theocracy
		coa_with_overlord_canton = JAP_subject
		allow_overlord_canton = yes
		priority = 20
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = JAP_usa
		priority = 30
		trigger = { 
			coa_def_american_ensign_trigger = yes
		}
	}	
	flag_definition = {
		coa = JAP_fascist
		subject_canton = JAP_fascist
		priority = 1500
		trigger = { 
			coa_def_fascist_flag_trigger = yes
		}
	}	
	
	# WB originals

	flag_definition = {
		coa = JAP_communist
		subject_canton = JAP_communist
		allow_overlord_canton = yes
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}

	flag_definition = {
		coa = JAP_anarchist
		subject_canton = JAP_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
	
	# For a Boshin War-like scenario 
	
	flag_definition = {
		coa = JAP_tokugawa
		priority = 1000
		allow_revolutionary_indicator = no
		trigger = {
			exists = scope:actor
			exists = c:JAP
			
			coa_def_secessionist_or_revolutionary_trigger = yes
			
			scope:actor = {
				is_secessionist = no
				ig:ig_landowners = {
					is_powerful = yes
					is_in_government = yes
				}
			}
			
			c:JAP = {
				has_journal_entry = je_meiji_restoration
				has_variable = anti_shogunate_civil_war
			}
			
		}
	}
	
	flag_definition = {
		coa = JAP_absolute_monarchy
		priority = 1001
		trigger = {
			exists = scope:actor
			
			scope:actor = {
				NOT = { has_ruling_interest_group = ig_landowners }
				
				ig:ig_landowners = {
					is_powerful = no
					is_in_government = no
				}
				
				has_journal_entry = je_meiji_restoration
				has_variable = anti_shogunate_civil_war
			}
			
		}
	}
}

KOR = { # Korea
	flag_definition = {
		coa = KOR_joseon # WB edit
		subject_canton = KOR_joseon	# WB edit
		allow_overlord_canton = yes		
		coa_with_overlord_canton = KOR_subject			
		priority = 1
	}
	flag_definition = {
		coa = KOR_subject_CHI
		subject_canton = KOR_subject_CHI		
		priority = 2
		trigger = { 
			coa_def_chinese_ensign_trigger = yes
		}	
	}
	flag_definition = {
		coa = KOR_communist
		subject_canton = KOR_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}	
	
	# WB originals
	
	flag_definition = {
		coa = KOR_republic
		subject_canton = KOR_republic
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = KOR_dictatorship
		subject_canton = KOR_dictatorship
		priority = 20
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = KOR_empire
		subject_canton = KOR_empire	
		allow_overlord_canton = yes		
		coa_with_overlord_canton = KOR_subject		
		priority = 5
		trigger = {
			scope:actor ?= {
				NOR = { 
					has_law = law_type:law_traditionalism
					has_law = law_type:law_industry_banned
				}
				has_law = law_type:law_monarchy
				has_technology_researched = nationalism
			}
		}	
	}
	
	flag_definition = {
		coa = KOR_empire_alt
		subject_canton = KOR_empire_alt	
		allow_overlord_canton = yes		
		coa_with_overlord_canton = KOR_subject		
		priority = 6
		trigger = {
			scope:actor ?= {
				NOR = { 
					has_law = law_type:law_traditionalism
					has_law = law_type:law_industry_banned
				}
				has_law = law_type:law_monarchy
				has_technology_researched = nationalism
				
				# This alt requires you to be recognized
				is_country_type = recognized
			}
		}	
	}
	
	flag_definition = {
		coa = KOR_anarchist
		subject_canton = KOR_anarchist
		priority = 1502
		trigger = {
			coa_def_anarchy_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = KOR_secessionist
		subject_canton = KOR_secessionist
		priority = 15
		trigger = {
			scope:actor ?= {
				is_secessionist = yes
			}
		}
	}
	
	flag_definition = {
		coa = KOR_communist_revolutionary
		subject_canton = KOR_communist_revolutionary
		priority = 1501
		trigger = {
			coa_def_communist_flag_trigger = yes
			coa_def_secessionist_or_revolutionary_trigger = yes
		}
	}
	
	flag_definition = {
		coa = KOR_secessionist_dictatorship
		subject_canton = KOR_secessionist_dictatorship
		priority = 16
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		
			scope:actor ?= {
				is_secessionist = yes
			}
		}
	}
	
	flag_definition = {
		coa = KOR_junta
		subject_canton = KOR_junta
		priority = 25
		trigger = {
			scope:actor ?= {
				OR = {
					has_ruling_interest_group = ig_armed_forces
				}
			
				OR = {
					has_law = law_type:law_presidential_republic
					has_law = law_type:law_parliamentary_republic
				}
				
				OR = {
					has_law = law_type:law_mass_conscription
					has_law = law_type:law_professional_army
				}
				
				OR = {
					country_has_voting_franchise = no
					has_law = law_type:law_oligarchy
					has_law = law_type:law_technocracy
					has_law = law_type:law_single_party_state
				}
				
				# Because this law triggers a different type of flag
				NOT = { has_law = law_type:law_autocracy }
			}
		}
	}
	
}

## South East Asia flag definitions ##

BUR = { # Burma
	flag_definition = {
		coa = BUR
		subject_canton = BUR
		allow_overlord_canton = yes		
		coa_with_overlord_canton = BUR_subject
		priority = 1
	}
	flag_definition = {
		coa = BUR_absolute_monarchy
		subject_canton = BUR_absolute_monarchy
		allow_overlord_canton = yes		
		coa_with_overlord_canton = BUR_subject		
		priority = 20
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = BUR_republic
		subject_canton = BUR_republic
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = BUR_dictatorship
		subject_canton = BUR_dictatorship
		priority = 20
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = BUR_theocracy
		subject_canton = BUR_theocracy
		priority = 20
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}	
	
	## WB originals
	
	flag_definition = {
		coa = BUR_communist
		subject_canton = BUR_communist
		priority = 1500
		trigger = {
			coa_def_communist_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = BUR_anarchist
		subject_canton = BUR_anarchist
		priority = 1501
		trigger = {
			coa_def_anarchy_flag_trigger = yes
		}
	}
}

DAI = { # Dai Nam
	flag_definition = {
		coa = DAI
		subject_canton = DAI
		allow_overlord_canton = yes		
		coa_with_overlord_canton = DAI_subject
		priority = 5
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
		}		
	}		
	flag_definition = {
		coa = DAI_monarchy
		subject_canton = DAI_monarchy
		allow_overlord_canton = yes
		coa_with_overlord_canton = DAI_subject		
		priority = 1
		trigger = { 
			coa_def_monarchy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = DAI_republic
		subject_canton = DAI_republic
		allow_overlord_canton = yes			
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}		
	flag_definition = {
		coa = DAI_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = DAI_fascist
		subject_canton = DAI_fascist
		priority = 1500
		trigger = { 
			coa_def_fascist_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = DAI_subject_FRA
		priority = 50
		trigger = { 
			coa_def_french_ensign_trigger = yes
		}
	}	
	
	# WB originals
	
	flag_definition = {
		coa = DAI_dictatorship
		subject_canton = DAI_dictatorship
		priority = 1500
		trigger = { 
			coa_def_dictatorship_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = DAI_theocracy
		subject_canton = DAI_theocracy
		allow_overlord_canton = yes
		coa_with_overlord_canton = DAI_subject
		priority = 20
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = DAI_anarchist
		subject_canton = DAI_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}

JOH = { # Johore
	flag_definition = {
		coa = JOH
		subject_canton = JOH
		allow_overlord_canton = yes	
		coa_with_overlord_canton = JOH_subject				
		priority = 1
	}
	flag_definition = {
		coa = JOH_absolute_monarchy
		subject_canton = JOH_absolute_monarchy
		allow_overlord_canton = yes	
		coa_with_overlord_canton = JOH_subject			
		priority = 15
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = JOH_republic
		subject_canton = JOH_republic
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}
	flag_definition = {
		coa = JOH_dictatorship
		subject_canton = JOH_dictatorship
		priority = 20
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = JOH_theocracy
		subject_canton = JOH_theocracy
		priority = 20
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}	
	
	
	# WB originals
	
	flag_definition = {
		coa = JOH_communist
		subject_canton = JOH_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = JOH_monarchy_modern
		subject_canton = JOH_monarchy_modern
		priority = 20
		allow_overlord_canton = yes	
		coa_with_overlord_canton = JOH_subject	
		trigger = {
			exists = scope:actor
			scope:actor = { 
				has_technology_researched = nationalism
				NOR = { 
					has_law = law_type:law_traditionalism
					has_law = law_type:law_industry_banned
				}
			}
			coa_def_monarchy_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = JOH_military
		subject_canton = JOH_military
		priority = 50
		trigger = {
			exists = scope:actor
			scope:actor = { 
				has_ruling_interest_group = ig_armed_forces
			}
			OR = {
				coa_def_military_junta_flag_trigger = yes
				coa_def_dictatorship_flag_trigger = yes
			}
		}
	}
	
	flag_definition = {
		coa = JOH_oligarchy
		subject_canton = JOH_oligarchy
		priority = 20
		trigger = { 
			coa_def_oligarchy_flag_trigger = yes
		}
	}
	
	# WB anarchist flags
	flag_definition = {
		coa = JOH_anarchist
		subject_canton = JOH_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}

LAN = { # Lanfang
	flag_definition = { # WB edit
		coa = LAN_monarchy
		subject_canton = LAN_monarchy
		allow_overlord_canton = yes		
		coa_with_overlord_canton = LAN_subject	
		priority = 1
	}
	flag_definition = {
		coa = LAN_subject_GBR
		allow_overlord_canton = yes		
		priority = 50
		trigger = { 
			coa_def_british_ensign_trigger = yes
		}
	}
	
	# WB originals
	
	flag_definition = {
		coa = LAN
		subject_canton = LAN
		allow_overlord_canton = yes		
		coa_with_overlord_canton = LAN_subject	
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = LAN_monarchy
		subject_canton = LAN_monarchy	
		priority = 10
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}	
	
	flag_definition = {
		coa = LAN_fascist
		subject_canton = LAN_fascist
		priority = 1500
		trigger = { 
			coa_def_fascist_flag_trigger = yes
		}
	}

	flag_definition = {
		coa = LAN_communist
		subject_canton = LAN_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = LAN_fascist
		subject_canton = LAN_fascist
		priority = 1500
		trigger = { 
			coa_def_dictatorship_flag_trigger = yes
		}
	}
	
	flag_definition = {
		coa = LAN_theocracy
		subject_canton = LAN_theocracy
		priority = 20
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}
	
	# WB anarchist flags
	flag_definition = {
		coa = LAN_anarchist
		subject_canton = LAN_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}

SIA = { # Siam
	flag_definition = {
		coa = SIA
		coa_with_overlord_canton = SIA_subject		
		allow_overlord_canton = yes		
		subject_canton = SIA
		priority = 1
	}
	flag_definition = {
		coa = SIA_absolute_monarchy
		subject_canton = SIA_absolute_monarchy
		coa_with_overlord_canton = SIA_subject		
		allow_overlord_canton = yes				
		priority = 20
		trigger = { 
			coa_def_absolute_monarchy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = SIA_republic
		subject_canton = SIA_republic
		priority = 10
		trigger = { 
			coa_def_republic_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = SIA_dictatorship
		subject_canton = SIA_dictatorship
		priority = 20
		trigger = {
			coa_def_dictatorship_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = SIA_theocracy
		subject_canton = SIA_theocracy
		priority = 20
		trigger = { 
			coa_def_theocracy_flag_trigger = yes
		}
	}	
	flag_definition = {
		coa = SIA_subject	
		allow_overlord_canton = yes	
		overlord_canton_offset = { 0.01 0.015 }
		overlord_canton_scale = { 0.48 0.47 }			
		priority = 50
		trigger = { 
			coa_def_french_ensign_trigger = yes
		}
	}	
	flag_definition = {
		coa = SIA_subject_gold
		allow_overlord_canton = yes	
		overlord_canton_offset = { 0.01 0.015 }
		overlord_canton_scale = { 0.48 0.47 }			
		priority = 50
		trigger = { 
			coa_def_spanish_ensign_trigger = yes
		}
	}	
	
	# WB originals
	
	flag_definition = {
		coa = SIA_communist
		subject_canton = SIA_communist
		priority = 1500
		trigger = { 
			coa_def_communist_flag_trigger = yes
		}
	}	
	
	# WB anarchist flags
	flag_definition = {
		coa = SIA_anarchist
		subject_canton = SIA_anarchist
		priority = 1501
		trigger = { 
			coa_def_anarchy_flag_trigger = yes
		}
	}
}


## Indonesia

IDN = { # Indonesia
	flag_definition = {
		coa = IDN
		subject_canton = IDN
		priority = 1
	}

	flag_definition = {
		coa = IDN_republic
		subject_canton = IDN_republic
		priority = 5
		trigger = {
			coa_def_republic_flag_trigger = yes
		}
	}

# Placeholders

	flag_definition = {
		coa = IDN_JOH
		subject_canton = IDN
		priority = 5
		
		trigger = {
			exists = scope:actor
			exists = c:IDN
			OR = {
				scope:actor = { has_variable = WB_is_Johor_var }
				c:IDN = {	capital = { state_region = s:STATE_MALAYA } }
			}
		}
	}

	flag_definition = {
		coa = IDN_JOH_republic
		subject_canton = IDN_republic
		priority = 10
		trigger = {
			exists = scope:actor
			exists = c:IDN
			coa_def_republic_flag_trigger = yes
			
			OR = {
				scope:actor = { has_variable = WB_is_Johor_var }
				c:IDN = {	capital = { state_region = s:STATE_MALAYA } }
			}
		}
	}
	
	flag_definition = {
		coa = IDN_JOH_communist
		subject_canton = IDN_JOH_communist
		priority = 1505
		trigger = {
			exists = scope:actor
			exists = c:IDN
			coa_def_communist_flag_trigger = yes
			
			OR = {
				scope:actor = { has_variable = WB_is_Johor_var }
				c:IDN = {	capital = { state_region = s:STATE_MALAYA } }
			}
		}
	}
	
	flag_definition = {
		coa = IDN_JOH_dictatorship
		subject_canton = IDN_JOH_dictatorship
		priority = 50
		trigger = {
			exists = scope:actor
			exists = c:IDN
			coa_def_dictatorship_flag_trigger = yes
			
			OR = {
				scope:actor = { has_variable = WB_is_Johor_var }
				c:IDN = {	capital = { state_region = s:STATE_MALAYA } }
			}
		}
	}
	
	# WB anarchist flags
	flag_definition = {
		coa = JOH_anarchist
		subject_canton = JOH_anarchist
		priority = 1501
		trigger = { 
			exists = scope:actor
			exists = c:IDN
			coa_def_anarchy_flag_trigger = yes
			
			OR = {
				scope:actor = { has_variable = WB_is_Johor_var }
				c:IDN = {	capital = { state_region = s:STATE_MALAYA } }
			}
		}
	}
}